package com.yjz.designpattern.strategy_pattern;

import com.yjz.designpattern.strategy_pattern.factory.LaunchPayFactory;
import com.yjz.designpattern.strategy_pattern.model.LaunchPayCommand;
import com.yjz.designpattern.strategy_pattern.model.LaunchPayResultBo;
import com.yjz.designpattern.strategy_pattern.strategy.LaunchPayStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: yuanjinzhong
 * @date: 2022/10/12 7:50 PM
 * @description:
 */
@Service
public class LaunchPayExecutor {

  @Autowired private LaunchPayFactory launchPayFactory;


  public LaunchPayResultBo lunchPay(LaunchPayCommand launchPayCommand) {

    /**
     * 前置逻辑处理
     */

    LaunchPayStrategy payStrategy =
        launchPayFactory
            .obtainStrategy(launchPayCommand.getCashierBizType())
            .orElseThrow(() -> new RuntimeException("业务类型错误"));

    return payStrategy.doLaunchPay(launchPayCommand, null);
  }




}
